package com.lingxu.api.ztb.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lingxu.api.ztb.mapper.HandoverAuditMapper;
import com.lingxu.api.ztb.model.HandoverAudit;
import com.lingxu.api.ztb.model.vo.LandUseSpecialReviewVO;
import com.lingxu.api.ztb.service.IHandoverAuditService;
import com.lingxu.api.ztb.model.vo.HandoverAuditVO;



import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.metadata.IPage;


import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;

/**
 * 交工审计表 服务实现类
 *
 * @author admin
 * @since 2025-08-15
 */
@Slf4j
@Service
public class HandoverAuditServiceImpl extends ServiceImpl<HandoverAuditMapper, HandoverAudit>  implements IHandoverAuditService {

    @Resource
    private HandoverAuditMapper handoverAuditMapper;

    @Transactional(readOnly = true)
    @Override
    public IPage<HandoverAuditVO> queryPageList(HandoverAuditVO query) {
        Page<HandoverAuditVO> page = new Page<HandoverAuditVO>(query.getPageNo(), query.getPageSize());
        return handoverAuditMapper.pageList(page,query);
    }


    @Transactional(readOnly = true)
    @Override
    public List<HandoverAuditVO> list(HandoverAuditVO query) {
        return handoverAuditMapper.selectHandoverAuditList(query);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(Set<String> ids) {
        if (CollectionUtils.isNotEmpty(ids)) {
            handoverAuditMapper.deleteBatchIds(ids);
        }
    }

    @Override
    public IPage<HandoverAuditVO> getPageList(HandoverAuditVO query) {
        int offset = (int) ((query.getPageNo() - 1) * query.getPageSize());
        int pageSize = Math.toIntExact(query.getPageSize());
        int total = handoverAuditMapper.countUnionList(query);
        List<HandoverAuditVO> records = handoverAuditMapper.selectUnionList(query, offset, pageSize);
        Page<HandoverAuditVO> page = new Page<>(query.getPageNo(), pageSize);
        page.setRecords(records);
        page.setTotal(total);
        return page;
    }

}
